﻿using System;
using System.Windows.Forms;
namespace Moonlite.Services.CodeCompletion
{
    public static class DynamicSyntaxCheckingScheduler
    {
        public static event EventHandler CheckTimeElapsed;
        private static Timer timer = new Timer();
        public static int Interval
        {
            get { return timer.Interval; }
            set { timer.Interval = value; }
        }
        public static bool Enabled
        {
            get { return timer.Enabled; }
            set { timer.Enabled = value; }
        }
        private static void TimerTick(object sender, EventArgs e)
        {
            if (Enabled)
            {
                if (CheckTimeElapsed != null)
                {
                    CheckTimeElapsed(null, e);
                }
            }
        }
        public static void Stop()
        {
            timer.Stop();
        }
        static DynamicSyntaxCheckingScheduler()
        {
            timer.Tick += TimerTick;
            timer.Enabled = false;
        }
    }
}
